package com.msconfig.mvp.view.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import com.geo.msconfig.R;
import com.msconfig.event.DebugCommandDialogDismissEvent;
import com.msconfig.mvp.view.adapter.DebugCommandsAdapter;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;

public class SetupDebugCommandDialogActivity extends Activity {
    private ArrayList<String> arrayList;
    private ListView listView;
    private TextView tvTitle;
    private DebugCommandsAdapter adapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_activity_ellipsoid_select_dialog);
        listView=findViewById(R.id.lv_listview);
        tvTitle=findViewById(R.id.title);
        tvTitle.setText("指令集");
        arrayList=new ArrayList<>();
        arrayList.add(getString(R.string.instrument_self_inspection));
        arrayList.add(getString(R.string.reset_motherboard));
        arrayList.add(getString(R.string.stop_message_output));
        arrayList.add(getString(R.string.message_output));
        arrayList.add(getString(R.string.host_restart));
        arrayList.add(getString(R.string.restore_factory_settings));
        arrayList.add(getString(R.string.read_motherboard_serial));
        arrayList.add(getString(R.string.read_motherboard_firmware_ver));
        arrayList.add(getString(R.string.apply_for_gga_output));
        arrayList.add(getString(R.string.gps_rtktimeout));
        arrayList.add(getString(R.string.close_gps_rtktimeout));
        arrayList.add(getString(R.string.direct_to_mainboard));
        adapter=new DebugCommandsAdapter(this,arrayList);
        listView.setAdapter(adapter);

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String command= (String) parent.getItemAtPosition(position);
                //更新参数设置页面
                EventBus.getDefault().post(new DebugCommandDialogDismissEvent(command));
                finish();

            }
        });
    }


}
